#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
int judge(int i)
{
	if (i % 100 == 0)
	{
		if (i % 400 == 0)
			return 1;
	}
	else
	{
		if (i % 4 == 0)
			return 1;
	}
	return 0;
}


int main() {
	int year, month, day;
	int num = 0;
	scanf("%d %d %d", &year, &month, &day);
	switch (month)
	{
	case 12:
		num += 30;
	case 11:
		num += 31;
	case 10:
		num += 30;
	case 9:
		num += 31;
	case 8:
		num += 31;
	case 7:
		num += 30;
	case 6:
		num += 31;
	case 5:
		num += 30;
	case 4:
		num += 31;
	case 3:
		if (judge(year))
			num += 29;
		else
			num += 28;
	case 2:
		num += 31;
	case 1:
		break;
	}
	num += day;
	printf("%d", num);
		return 0;
}